﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using System.Data;

namespace System.Web.UI
{

    public class AnalyticsListBase : AnalyticsListBase<BaseModel>
    {
    }
    public class AnalyticsListBase<T> : ZMPageList<T>
        where T : BaseModel, new()
    {

        private void InitExcel()
        {
            ImageButton ibtnExcel = new ImageButton();
            ibtnExcel.ID = "ToolBarExcel";
            ibtnExcel.ImageUrl = ZPath.ImagesURI + "ToolBar" + GetLanguage() + "ImgExcel.GIF";
            ibtnExcel.Click += new ImageClickEventHandler(OnExcelClick);
            BaseToolBar.Controls.Add(ibtnExcel);
        }

        protected virtual string[,] ExcelHeader
        {
            get
            {
                return null;
            }
        }

        protected override void SetControlsProperty()
        {
            base.SetControlsProperty();
            if (BaseMainGrid != null)
                BaseMainGrid.DataKeyNames = new string[] { };
        }
        protected virtual DataTable MainDateTable
        {
            get { return (DataTable)ViewState["_dtGridView"]; }
            set { ViewState["_dtGridView"] = value; }
        }
        protected override void InitToolBar()
        {
            base.InitToolBar();
            //InitExcel();
        }
        protected override string DefaultSortField
        {
            get
            {
                return "GID";
            }
        }
        protected override void InitBtnDelete()
        {
        }
        protected override void InitBtnAdd()
        {
        }
        protected override void InitBtnSave()
        {
        }
        protected virtual void OnExcelClick(object sender, ImageClickEventArgs e)
        {
            if (BaseMainGrid != null)
            {
                ExportExcel.PrepareGridViewForExport(BaseMainGrid);
                ExportExcel.ExportGridView(BaseMainGrid, "Data" + DateTime.Now.ToString("yyyyMMddHHmmss").Replace("-", ""));
            }
        }
    }
}
